package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.MediaDirectorBindMapper;
import com.weixing.mall.provider.model.domain.MediaDirectorBind;
import com.weixing.mall.provider.model.dto.ads.MediaDirectorBindDto;
import com.weixing.mall.provider.model.query.MediaDirectorBindQuery;
import com.weixing.mall.provider.model.vo.ads.MediaDirectorBindVo;
import com.weixing.mall.provider.service.IMediaDirectorBindService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 广告专员与广告客服绑定关系表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-18
 */
@Service
public class MediaDirectorBindServiceImpl extends ServiceImpl<MediaDirectorBindMapper, MediaDirectorBind> implements IMediaDirectorBindService {

    @Override
    public IPage<MediaDirectorBindVo> selectOfPage(Page initMpPage, MediaDirectorBindQuery mediaDirectorBindQuery) {
        return baseMapper.selectOfPage(initMpPage,mediaDirectorBindQuery);
    }

    @Override
    public List<MediaDirectorBindVo> getList(MediaDirectorBindQuery mediaDirectorBindQuery) {
        return baseMapper.selectOfPage(mediaDirectorBindQuery);
    }

    @Override
    public void save(MediaDirectorBindDto mediaDirectorBindDto) {
        MediaDirectorBind mediaDirectorBind = new MediaDirectorBind();
        BeanUtils.copyProperties(mediaDirectorBindDto,mediaDirectorBind);
        if(null==mediaDirectorBindDto.getId()){
            save(mediaDirectorBind);
        }else{
            mediaDirectorBind.setUpdatedTime(new Date());
            updateById(mediaDirectorBind);
        }
    }
}
